<?php

namespace App\Models;

use App\Models\Base\WorkTicketDetail as BaseWorkTicketDetail;

/**
 * 
 *
 * @property int $id
 * @property int $work_ticket_id 工单id
 * @property int $related_id 关联id
 * @property string $related_type 关联类型,关联表的表名
 * @property string $content 内容
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property \Illuminate\Support\Carbon|null $deleted_at
 * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\WorkTicketImage> $images
 * @property-read int|null $images_count
 * @property-read \Illuminate\Database\Eloquent\Model|\Eloquent $related
 * @property-read \App\Models\WorkTicket|null $workTicket
 * @method static \Illuminate\Database\Eloquent\Builder|WorkTicketDetail newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|WorkTicketDetail newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|WorkTicketDetail onlyTrashed()
 * @method static \Illuminate\Database\Eloquent\Builder|WorkTicketDetail query()
 * @method static \Illuminate\Database\Eloquent\Builder|WorkTicketDetail whereContent($value)
 * @method static \Illuminate\Database\Eloquent\Builder|WorkTicketDetail whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|WorkTicketDetail whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|WorkTicketDetail whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|WorkTicketDetail whereRelatedId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|WorkTicketDetail whereRelatedType($value)
 * @method static \Illuminate\Database\Eloquent\Builder|WorkTicketDetail whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|WorkTicketDetail whereWorkTicketId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|WorkTicketDetail withTrashed()
 * @method static \Illuminate\Database\Eloquent\Builder|WorkTicketDetail withoutTrashed()
 * @mixin \Eloquent
 */
class WorkTicketDetail extends BaseWorkTicketDetail
{
	protected $fillable = [
		self::WORK_TICKET_ID,
		self::RELATED_ID,
		self::RELATED_TYPE,
		self::CONTENT
	];

	public function workTicket()
	{
		return $this->belongsTo(WorkTicket::class, self::WORK_TICKET_ID);
	}

	public function images()
	{
		return $this->hasMany(WorkTicketImage::class, WorkTicketImage::WORK_TICKET_DETAIL_ID, self::ID);
	}

	public function related()
	{
		return $this->morphTo('related',self::RELATED_TYPE, self::RELATED_ID);
	}
}
